//
//  SearchEngine.swift
//  YoruNeko
//
//  Created by Kotori on 2021/6/21.
//

import Foundation

class SearchEngine : Identifiable {
    init(name: String, domain: String, searchPrefix: String) {
        self.name = name
        self.domain = domain
        self.searchPrefix = searchPrefix
    }
    let id: UUID = UUID()
    var name: String
    //搜索引擎首页
    var domain: String
    //搜索前缀 在后面加上搜索关键字便成为合法的搜索URL
    var searchPrefix: String
    
    //返回搜索引擎列表，用户偏好设置中存有用户所选搜索引擎偏移量，通过偏移量选择对应搜索前缀进行搜索操作
    //目前采用在代码中写搜索引擎列表的方法，后期考虑加入到文件中存储搜索引擎列表
    static func searchEngineList() -> [SearchEngine] {
        var list: [SearchEngine] = []
        list.append(SearchEngine(name: "百度", domain: "https://www.baidu.com", searchPrefix: "https://www.baidu.com/s?wd="))
        list.append(SearchEngine(name: "谷歌", domain: "https://www.google.com", searchPrefix: "https://www.google.com/search?q="))
        return list
    }
}
